#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <network/dual_stack_socket.h>


int main(int argc, char** argv)
{
    unsigned int index = 0;
    char buf[1024] = {0};

    char* dest = "::1";
    int port = 11024;
    unsigned int num  = 10;

    if (argc >= 4)
    {
        dest = argv[1];
        port = atoi(argv[2]);
        num = (unsigned int)atoi(argv[3]);
    }

    dualstack_socket_t s = create_dual_socket(dest, port, protocol_type_udp);

    if (!s)
    {
        printf("Create socket failed!\n");
        exit(1);
    }


    for (index = 0; index < num; ++index)
    {
        sprintf(buf, ">>>> %d\n", index);
        sendto(get_socket_fd(s), buf, strlen(buf) + 1, 0, get_sockaddr(s), get_sockaddr_len(s));
    }

    printf("Send Ok!\n");

    destroy_dual_socket(s);

    return 0;
}

